class Strategy {
    constructor(name) {
        this.name = name
    }
    execute () { }
}

class StrategyA extends Strategy {
    execute () {
        console.log(this.name, 'A')
    }
}
class StrategyB extends Strategy {
    execute () {
        console.log(this.name, 'B')
    }
}
class Context {
    constructor(strategy) {
        this.strategy = strategy
    }
    executeStrategy () {
        this.strategy.execute()
    }
}

let context = new Context(new StrategyA('A'))
context.executeStrategy()

context.strategy = new StrategyB('B1')
context.executeStrategy()